# Maintainer: Jelle van der Waa <jelle@archlinux.org>

_hkgname=classy-prelude
pkgname=haskell-classy-prelude
pkgver=1.5.0.2
pkgrel=64
pkgdesc='A typeclass-based Prelude'
arch=(loong64 x86_64)
url="https://hackage.haskell.org/package/$_hkgname"
license=(MIT)
depends=(ghc-libs haskell-async haskell-chunked-data haskell-dlist
         haskell-hashable haskell-mono-traversable haskell-primitive
         haskell-unliftio haskell-stm-chans
         haskell-unordered-containers haskell-vector-instances
         haskell-say haskell-mutable-containers haskell-basic-prelude
         haskell-mono-traversable-instances)
checkdepends=(haskell-hspec)
makedepends=(ghc)
source=("https://hackage.haskell.org/packages/archive/$_hkgname/$pkgver/$_hkgname-$pkgver.tar.gz")
sha512sums=('4cc39f6da6f10e38a82fa189445df3dfc9ae2383fba6c6142dcabf4ed65fa8cd7784618d44fe8f2f498dda7ef0ea004853adcde932817098d67ee3558707b62d')

build() {
  cd $_hkgname-$pkgver
  runhaskell Setup configure -O --enable-shared --enable-executable-dynamic --disable-library-vanilla \
      --prefix=/usr --docdir=/usr/share/doc/$pkgname --datasubdir=$pkgname --enable-tests \
      --dynlibdir=/usr/lib --libsubdir=\$compiler/site-local/\$pkgid --ghc-option=-fllvm
  runhaskell Setup build $MAKEFLAGS
  runhaskell Setup register --gen-script
  runhaskell Setup unregister --gen-script
  sed -i -r -e "s|ghc-pkg.*update[^ ]* |&'--force' |" register.sh
  sed -i -r -e "s|ghc-pkg.*unregister[^ ]* |&'--force' |" unregister.sh
}

check() {
  cd $_hkgname-$pkgver
  runhaskell Setup test --show-details=direct
}

package() {
  cd $_hkgname-$pkgver
  install -D -m744 register.sh "$pkgdir"/usr/share/haskell/register/$pkgname.sh
  install -D -m744 unregister.sh "$pkgdir"/usr/share/haskell/unregister/$pkgname.sh
  runhaskell Setup copy --destdir="$pkgdir"
  install -D -m644 LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
  rm -f "$pkgdir"/usr/share/doc/$pkgname/LICENSE
}

# vim: ts=2 sw=2 et:
